cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME1 "main")
set(CMAKE_BUILD_TYPE "Release")
set(PROJ_DIR "/home/star/get_capture")

project(${PROJECT_NAME1})

find_package(OpenCV REQUIRED)
# message(STATUS "OpenCV library status:")
# message(STATUS "    config: ${OpenCV_DIR}")
# message(STATUS "    version: ${OpenCV_VERSION}")
# message(STATUS "    libraries: ${OpenCV_LIBS}")
# message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

find_package(CUDA REQUIRED)
if(CUDA_FOUND)
    message(STATUS "CUDA找到:  ${CUDA_INCLUDE_DIRS}, 版本: ${CUDA_VERSION}")
else()
    message(FATAL_ERROR "未找到CUDA! ")
endif()

find_path(TENSORRT_INCLUDE_DIR
    NAMES NvInfer.h NvInferRuntime.h
    PATHS /usr/include/aarch64-linux-gnu
    )
find_library(TENSORRT_LIBRARY
    NAMES nvinfer nvinfer_runtime
    PATHS /usr/lib/aarch64-linux-gnu
    )
if(TENSORRT_INCLUDE_DIR AND TENSORRT_LIBRARY)
    message(STATUS "TensorRT找到: 头文件=${TENSORRT_INCLUDE_DIR}, 库=${TENSORRT_LIBRARY}")
else()
    message(FATAL_ERROR "未找到TensorRT! ")
endif()

include_directories("${PROJ_DIR}/include" 
                    "/usr/include/X11" 
                    "/usr/include" 
                    "${PROJ_DIR}/src"
                    ${OpenCV_INCLUDE_DIRS}
                    ${CUDA_INCLUDE_DIRS}
                    ${TENSORRT_INCLUDE_DIR}
                    )

link_directories(/opt/MVS/lib/aarch64/)
link_directories(/usr/lib/aarch64-linux-gnu/)
link_libraries("/opt/MVS/lib/aarch64/libMvCameraControl.so")
add_compile_options(-std=c++17)

set(SOURCES ${PROJECT_SOURCE_DIR}/main.cpp
            ${PROJECT_SOURCE_DIR}/src/camera_class.cpp)

add_executable(${PROJECT_NAME1} ${SOURCES})

target_link_libraries(${PROJECT_NAME1}
                      ${OpenCV_LIBS}
                      -lX11
                      MvCameraControl
                      pthread
                      ${CUDA_LIBRARIES}
                      nvinfer
                      dl
                      )

